from selenium.webdriver.common.by import By

from pages.basepage import Base


class ContactPage(Base):
    # 通讯录页面的起始页面
    _base_url = "https://work.weixin.qq.com/wework_admin/frame#contacts"
    _index_button = (By.CSS_SELECTOR, ".frame_nav_item_title")

    def get_contact_list(self):
        pass

    def get_phone_list(self):
        """
        定位表格里手机号列，并获取手机号列表并返回
        :return: 手机号列表
        """

        datas = self.driver.find_elements(By.CSS_SELECTOR, "#member_list>tr>td:nth-child(5)")

        print(datas)
        phone_list = []
        for item in datas:
            phone_list.append(item.text)
        # 跳转到首页
        self.goto_index()
        return phone_list

    def goto_index(self):
        # 点击首页按钮
        self.find(self._index_button).click()
        from pages.indexpage import IndexPage
        return IndexPage(self.driver)
